<template>
	<view class="container">
		<view class="list">
		<scroll-view :scroll-top="scrollTop" :scroll-into-view="scrollId" :scroll-with-animation="true" class="scrollView" @scroll="scroll" scroll-y="true"
			:style="{'height':rootHeight + 'px'}">
			<view class="item-box" v-for="(item,index) in indexList" :item="item" :key="index" :id="getId(item.date)">
				<view class="header-nav" @click="$refs.YearMouth.open()">
					<text>{{item.date}}</text>
					<image :src="$img_path('/pagesRegion/27.png')" mode="widthFix"></image>
				</view>
				<view class="all-info">
					<text>已缴纳：10人</text>
					<text>已缴费用：￥2000.00</text>
				</view>
				<view class="item-child" v-for="item in 14">
					<view class="name-price">
						<text class="name">张三</text>
						<text class="price">￥10.00</text>
					</view>
					<view class="time">
						2024-05-21  16:00
					</view>
				</view>
			</view>
			</scroll-view>
		</view>
		<dateYearMouth ref="YearMouth" :dateValue="dateValue" @change="selectDate"></dateYearMouth>
	</view>
</template>

<script>
	import dateYearMouth from '@/components/popup-picker/date-year-mouth.vue'
	export default {
		components: {
			dateYearMouth
		},
		data() {
			return {
				rootHeight:null,
				scrollId:null,
				newScrollTop:null,
				scrollTop: 0,
				// 选择时间
				dateValue:'2024-05',
				indexList:[
					{
						date:'2024-08',
					},
					{
						date:'2024-07',
					}
				]
			};
		},
		created() {
			const info = uni.getSystemInfoSync();
			this.rootHeight = info.windowHeight - info.safeAreaInsets.bottom;
		},
		mounted() {
			this.scrollId = 'item_'+this.$dayjs(this.indexList[0].date).format('YYYYMM')
		},
		methods:{
			getId(date){
				return 'item_'+this.$dayjs(date).format('YYYYMM')
			},
			scrollToId(date){
				this.scrollId = 'item_'+this.$dayjs(date).format('YYYYMM')
			},
			selectDate(val){
				console.log(val,'--')
				this.scrollToId(val)
			},
			scroll(e){
				this.newScrollTop = e.detail.scrollTop;
			}
			
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
.container{
	.list{
		.item-box{
			.header-nav{
				position: sticky;
				top: 0;
				padding: 10rpx 22rpx;
				box-sizing: border-box;
				background-color: #E72A2A;
				display: flex;
				align-items: center;
				text{
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 40rpx;
				}
				image{
					width: 25rpx;
					height: 14rpx;
					margin-left: 18rpx;
				}
			}
			.all-info{
				padding: 18rpx 22rpx 10rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				text{
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
				}
			}
			.item-child{
				padding: 20rpx 22rpx 22rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #EEEEEE;
				.name-price{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.name{
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
						line-height: 40rpx;
					}
					.price{
						font-weight: bold;
						font-size: 28rpx;
						color: #FF4A4A;
						line-height: 40rpx;
					}
				}
				.time{
					font-weight: 400;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
					margin-top: 12rpx;
				}
			}
		}
	}
}
</style>
